home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11562 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: cs.tu-berlin.de!news
  2. From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: works in Borland but not in Microsuck Visual C++
  5. Date: Fri, 15 Mar 1996 03:48:33 +0100
  6. Organization: Technical University of Berlin
  7. Message-ID: <3148DA81.20F9@cs.tu-berlin.de>
  8. References: <4ia6h8$jes@news.vanderbilt.edu>
  9. NNTP-Posting-Host: 130.149.17.231
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14.  
  15. Bennett Haselton wrote:
  16. >         Dear Abby,
  17. >                 The following program was written in completely standard C++
  18. > and should be portable across platforms.  However, it only performs as
  19. > expected (i.e. sends two copies of 4 to the standard out stream) in Borland
  20. > C++; when compiled in MicroSUCK Visual C++, it outputs 4 followed by a random
  21. > integer in the thousands.
  22. > #include <iostream.h>
  23. > struct person {
  24. >         int age;
  25. > };
  26. > struct person* matchPerson( struct person* psnPtr )
  27. > {
  28. >         struct person* ansPtr;
  29. >         ansPtr->age = psnPtr->age;
  30.  
  31. How about initializing the pointer? ansPtr can point anywhere so don't be 
  32. surprised about the output you get.
  33.  
  34. >         cout << ansPtr->age;
  35. >         cout << ansPtr->age;
  36. >         return ansPtr;
  37. > };
  38. > void main()
  39. > {
  40. >         struct person myperson;
  41. >         myperson.age = 4;
  42. >         struct person* k = matchPerson( &myperson );
  43. > }
  44. > i was using version 1.0 of Visual C++; i have no knowledge of whether later
  45. > Microsuck compilers are capable of handling a program like this properly.
  46. > Please avoid buying their products whenever possible if you have not already
  47. > resolved to do so.
  48. >         Is there a further explanation of this anomaly which i did not come
  49. > across?  As usual, great Microsuck jokes will be mailed to anyone who can
  50. > help.  Thanks!
  51. >         Love,
  52. >                 tm
  53. >         -bennett
  54.  
  55. When do I get the jokes? ;-)
  56.  
  57. Bye
  58.  
  59. Roman
  60.